package com.qingcheng.handler;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @ClassName ConstantPropertiesUtil
 * @Description @InitializingBean 初始化设置
 * @Author Simon
 * @Date 2020/5/25 20:28
 * @Version 1.0
 **/

@Component // 实例化
public class ConstantPropertiesUtil implements InitializingBean {

    @Value("${aliyun.oss.file.endpoint}") //spring注入val给参数endpoint
    private String endpoint;

    @Value("${aliyun.oss.file.keyid}")
    private String keyId;

    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;

    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    // @Value("${aliyun.oss.file.host}")
    private String host;

    // 定义全局变量，方便调用
    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    public static String HOST;

    /**
     * @Author chengpunan 
     * @Description // 服务器启动的时候，ConstantPropertiesUtil初始化，调用里面afterPropertiesSet读取文件内容
     * @Date 20:32 2020/5/25
     * @Param
     * @return 
     **/
    
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
        HOST = host;
    }
}
